<template>
    <div>
        <div style="border-top: 2px solid #1CBBB4;box-sizing: border-box;padding: 0 210px;display: flex;align-items:center;height: 49px;width: 100%;background-color: #FAFAFA">
            <div style=";width: 100%;display: flex;justify-content: space-between">
                <div style="height: 20px;display: flex">
                    <span style="color: #ACACAC">
                        <i class="el-icon-s-cooperation"></i>
                                                support@travelagency.com
                    </span>
                    <span style="margin-left: 10px;border-left: 1px solid #EBEBEB;display:block;height: 20px;width: 1px"></span>
                    <span style="margin-left: 10px  ;color: #636363">
                                                   <i class="el-icon-phone"></i> +917 3386831
                        </span>
                </div>
                <div style="height: 20px">
                      <span v-if="!isLogin">
                            <i class="el-icon-shopping-cart-2"></i>
                             <span style="" @click="toPay" class="login">
                                                                我的订单
                                    </span>

                        </span>
                    <span v-if="!isLogin">
                            <i class="el-icon-user"></i>
                             <span style="" @click="toAdmin" class="login">
                             欢迎   {{realname}}
                                    </span>

                        </span>
                    <span v-if="isLogin">
                            <i class="el-icon-user"></i>
                             <span style="" @click="toLogin" class="login">
                                                                登录
                                    </span>

                        </span>
                    <span v-if="isLogin">
                            <i class="el-icon-loading"></i>
                            <span @click="toRegister" class="register" style="margin-left: 5px">注册</span>
                        </span>
                </div>
            </div>
        </div>

    </div>
</template>

<script>
    import jwtDecode from "jwt-decode";

    export default {
        name: "IndexTop",
        data() {
            return {
                isLogin: true,
                realname: '',
                cityList:[]
            }
        },
        created() {
            let token = jwtDecode(localStorage.getItem('token'))
            if (token){
                this.isLogin=false;
            }
            this.realname = token.realname;
        },
        methods: {
            toAdmin(){
                this.$router.push('/admin')
            },
            toLogin() {
                this.$router.push('/login')
            },
            toRegister() {
                this.$router.push('/register')

            },
            toPay() {
                this.$router.push('/order')

            }
        }
    }
</script>

<style scoped>

</style>